//
//  DateTool.m
//  TenMinDemo
//
//  Created by Shawn Li on 2021/3/13.
//  Copyright © 2021 CYXiang. All rights reserved.
//

#import "DateTool.h"

@implementation DateTool

//yyyy-MM-dd HH:mm:ss

+ (NSString *)timeStrWithTime:(NSTimeInterval)time{
    if (time > 999999999999) {
        time = time / 1000;
    }
    NSDate *date = [[NSDate alloc]initWithTimeIntervalSince1970:time];

    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];

    [formatter setDateFormat:@"HH:mm"];

    NSString*timeString=[formatter stringFromDate:date];
    return timeString;
}

+ (NSString *)yearDateStrWithTime:(NSTimeInterval)time{
    if (time > 999999999999) {
        time = time / 1000;
    }
    NSDate *date = [[NSDate alloc]initWithTimeIntervalSince1970:time];

    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];

    [formatter setDateFormat:@"MM/dd/yyyy"];

    NSString*timeString=[formatter stringFromDate:date];
    return timeString;
}

+ (NSString *)timeDateYearStrWithTime:(NSTimeInterval)time{
    if (time > 999999999999) {
        time = time / 1000;
    }
    
    //
    NSDate *date = [[NSDate alloc]initWithTimeIntervalSince1970:time];

    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];

    [formatter setDateFormat:@"HH:mm MM/dd/yyyy"];

    NSString*timeString=[formatter stringFromDate:date];
    return timeString;
}

+ (NSString *)timeDetailYearStrWithTime:(NSTimeInterval)time{
    if (time > 999999999999) {
        time = time / 1000;
    }
    //yyyy-MM-dd HH:mm:ss
    //
    NSDate *date = [[NSDate alloc]initWithTimeIntervalSince1970:time];

    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];

    [formatter setDateFormat:@"HH:mm:ss MM/dd/yyyy"];

    NSString*timeString=[formatter stringFromDate:date];
    return timeString;
}

@end
